import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JPanel;
import javax.swing.ImageIcon;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.Date;
import java.util.Calendar;

public class driverInterface extends JFrame implements ActionListener
{
  private JButton driverView = new JButton("View your timetable!");
  private JButton request = new JButton("Request Holiday!");
  private JButton back = new JButton("Back");
  private Container content3;
  private int driverID;
  
  // Construct a new window
  public driverInterface(int requestDriverID)
  {
    driverID = requestDriverID;
    content3 = getContentPane();
    setTitle("Driver interface");
    content3.setLayout(new GridLayout(0, 1));
    content3.add(new JLabel("Hello, " + DriverInfo.getName(requestDriverID)));
    
    content3.add(new JLabel("What do you want to do?                       "));
    // create a new button and add it to the contents
    content3.add(driverView);
    // add a ActionListener for this button
    driverView.addActionListener(this);
    // add in the contents a textlabel 
    content3.add(request);
    request.addActionListener(this);
    // display the result in the restultextfield
    //  contents.add(resultJTextField);
    // exit the program in case the window it's closed
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    pack();
  }
  
  private DViewInterface first;
  private requestInterface second;
  private iniInterface ini;
  public void actionPerformed(ActionEvent event)
  {
    if (event.getSource() == driverView)
    {
      dispose();
      first = new DViewInterface(DriverInfo.getName(driverID), driverID);
      first.setVisible(true);
    }
    else if (event.getSource() == request)
    {
      dispose();
      second = new requestInterface(driverID);
      second.setVisible(true);
    } // actionPerformed
    else if (event.getSource() == back)
    {
	 dispose();
	 ini = new iniInterface();
	 ini.setVisible(true);
    }
  }

} // class
